#include <ntddk.h>

VOID
DriverUnload(_In_ PDRIVER_OBJECT DriverObject);

VOID
KstartRoutine(_In_ PVOID StartContext);

EXTERN_C
NTSTATUS
DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegisterPath)
{
	DriverObject->DriverUnload = DriverUnload;

	OBJECT_ATTRIBUTES ObjectAttributes;
	InitializeObjectAttributes(
		&ObjectAttributes, 
		nullptr, 
		OBJ_KERNEL_HANDLE,
		nullptr, 
		nullptr);

	HANDLE ThreadHandle;
	NTSTATUS CreateStatus = IoCreateSystemThread(
		DriverObject, 
		&ThreadHandle, 
		SYNCHRONIZE, 
		&ObjectAttributes, 
		ZwCurrentProcess(), 
		nullptr,
		KstartRoutine, 
		nullptr);

	if (NT_SUCCESS(CreateStatus) == FALSE) {
		KdPrint(("IoCreateSystemThread Error: 0X%X\n", CreateStatus));
	}

	KdPrint(("Driver loaded successfully\n"));

	return STATUS_SUCCESS;
}

VOID
DriverUnload(_In_ PDRIVER_OBJECT DriverObject)
{
	KdPrint(("Driver uninstalled successfully\n"));
}

VOID
KstartRoutine(_In_ PVOID StartContext)
{
	KdPrint(("KstartRoutine: Hello World\n"));
}